#ifndef WORKER_HPP
#define WORKER_HPP

#include <QThread>

#include "qcustomplot.h"

struct Record {
    double energyLevel;
    QVector<double> psi;
};

Q_DECLARE_METATYPE(Record)

struct Result {
    QVector<Record> records;
    void addData(double E,QVector<double> vec){
        Record rec;
        rec.energyLevel = E;
        rec.psi = vec;
        records.push_back(rec);
    }
    void addData(Result res){
        if(!res.records.empty()){
            for (int i = 0; i < res.records.size(); ++i){
                records.push_back(res.records.at(i));
            }
        }
    }
};

Q_DECLARE_METATYPE(Result)

struct Input {
    QVector<double> vec_v;
    QVector<double> vec_mass;
};

Q_DECLARE_METATYPE(Input)

class Worker : public QThread {
    Q_OBJECT
public:
    explicit Worker(QObject *parent = 0);

    virtual void run() Q_DECL_OVERRIDE;

    void setRozmiar(double rozm);
    void setSigma(double sigma);
    void setPartitions(int n);
    void setInput(Input);
    void setVB(bool);

signals:
    void ready(Result);
    void notifyProgress(int);

public slots:

private:
    void oblicz_ww();
    void rysuj();


    QVector<double> generuj_potencjal(double , double, int);
    double lww(double, const QVector<double> , const double);
    double wartosc_wlasna( const QVector<double>,const double, int,double, double, double);
    double minimum(QVector<double>);
    double maksimum(QVector<double>);
    QVector<double> zbewymiaruj(QVector<double>,double,double);

    bool valence_band;
    double rozmiar_a;
    double sigma;
    int n_podzialow;
    Input m_input;
};

#endif // WORKER_HPP
